﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using University.Workshop.Business;

namespace University.Workshop.Presenters.Square.Register
{
    public class PresenterSecondStepForRegisterSquare
    {
        ISecondStepForRegisterSquare view;
        public PresenterSecondStepForRegisterSquare(ISecondStepForRegisterSquare view)
        {
            this.view = view;
        }

        public void UpdateData()
        {
            view.Allotments = view.AllotmentsToRegister;
       
        }

        public void ChargeDataMedicineProduct()
        {
            view.AllotmentsToRegister = view.Allotments;
        }
        public void AddAllotmentToList()
        {
            try
            {
                string AllotmentName = view.NameNewAllotment;
                view.Allotments=ManagerAllotment.AddNewAllotmentToList(AllotmentName, view.Allotments);
                view.NameNewAllotment = string.Empty;
            }
            catch (Exception ex)
            {
                view.ErrorMessage=ex.Message;
            }
        }
        public void DeleteAllotmentInList()
        {
            ICollection<Model.Allotment> a = view.Allotments;
            a.Remove(view.AllotmentSelected);
            view.Allotments = a;
        }
    }
}